import os
import shutil

def delExp():
    # 指定目录路径
    directory = './runs/detect'

    # 获取目录下所有文件夹的列表
    folders = [f for f in os.listdir(directory) if os.path.isdir(os.path.join(directory, f))]

    # 遍历文件夹列表，删除包含特定名称的文件夹
    for folder in folders:
        if 'exp' in folder:
            folder_path = os.path.join(directory, folder)
            # print(f"Deleting folder: {folder_path}")
            shutil.rmtree(folder_path)  # 使用shutil.rmtree递归删除文件夹及其内容
